import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

@Schema({ timestamps: true })
export class Template extends Document {
  @Prop({ required: true, unique: true })
  ID: string;

  @Prop({ required: true })
  previewUrl: string;

  @Prop({ required: false })
  NAME: string;

  @Prop({ required: true })
  EMAIL: string;

  @Prop({ default: 0 })
  LIKES: number;

  @Prop({ default: 0 })
  VIEWS: number;

  @Prop({
    type: {
      name: String,
      userId: String,
      avatar: String,
    },
    required: true,
  })
  userInfo: {
    name: string;
    userId: string;
    avatar: string;
  };

  @Prop({ default: 0 })
  commentCount: number;
}

export const TemplateSchema = SchemaFactory.createForClass(Template); 